// 路由守卫
import React from 'react'
import { Navigate, useNavigate } from 'react-router-dom'
import { useLocation } from 'react-router-dom'
function useGaojie(Com) {
 const token=localStorage.getItem('token')
 return function Fn(){
    const location=useLocation()
    let bai=['/login','/404']
    if(bai.includes(location.pathname)){
        return <Navigate to={location.pathname}></Navigate>
    }
    if(token){
        return <Com></Com>
    }else{
        return <Navigate to={'/login'}></Navigate>
    }
 }
}
export default useGaojie
